package com.ruoyi.handing.service.impl;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.ruoyi.handing.domain.AlgsHandingRecord;
import com.ruoyi.handing.mapper.AlgsHandingRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.handing.mapper.AlgsAnimalHandingMapper;
import com.ruoyi.handing.domain.AlgsAnimalHanding;
import com.ruoyi.handing.service.IAlgsAnimalHandingService;

import javax.annotation.Resource;

/**
 * 动物处理Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-17
 */
@Service
public class AlgsAnimalHandingServiceImpl implements IAlgsAnimalHandingService 
{
    @Autowired
    private AlgsAnimalHandingMapper algsAnimalHandingMapper;
    @Resource
    private AlgsHandingRecordMapper algsHandingRecordMapper;

    /**
     * 查询动物处理
     * 
     * @param animalHandingId 动物处理主键
     * @return 动物处理
     */
    @Override
    public AlgsAnimalHanding selectAlgsAnimalHandingByAnimalHandingId(Long animalHandingId)
    {
        return algsAnimalHandingMapper.selectAlgsAnimalHandingByAnimalHandingId(animalHandingId);
    }

    /**
     * 查询动物处理列表
     * 
     * @param algsAnimalHanding 动物处理
     * @return 动物处理
     */
    @Override
    public List<AlgsAnimalHanding> selectAlgsAnimalHandingList(AlgsAnimalHanding algsAnimalHanding)
    {
        return algsAnimalHandingMapper.selectAlgsAnimalHandingList(algsAnimalHanding);
    }

    /**
     * 新增动物处理
     * 
     * @param algsAnimalHanding 动物处理
     * @return 结果
     */
    @Override
    public int insertAlgsAnimalHanding(AlgsAnimalHanding algsAnimalHanding)
    {
        return algsAnimalHandingMapper.insertAlgsAnimalHanding(algsAnimalHanding);
    }

    /**
     * 修改动物处理
     * 
     * @param algsAnimalHanding 动物处理
     * @return 结果
     */
    @Override
    public int updateAlgsAnimalHanding(AlgsAnimalHanding algsAnimalHanding)
    {
        return algsAnimalHandingMapper.updateAlgsAnimalHanding(algsAnimalHanding);
    }

    /**
     * 批量删除动物处理
     * 
     * @param animalHandingIds 需要删除的动物处理主键
     * @return 结果
     */
    @Override
    public int deleteAlgsAnimalHandingByAnimalHandingIds(Long[] animalHandingIds)
    {
        return algsAnimalHandingMapper.deleteAlgsAnimalHandingByAnimalHandingIds(animalHandingIds);
    }

    /**
     * 删除动物处理信息
     * 
     * @param animalHandingId 动物处理主键
     * @return 结果
     */
    @Override
    public int deleteAlgsAnimalHandingByAnimalHandingId(Long animalHandingId)
    {
        return algsAnimalHandingMapper.deleteAlgsAnimalHandingByAnimalHandingId(animalHandingId);
    }

    @Override
    public int chuli(Long animalHandingId) {
        Date date = new Date();
//        DateFormat dateInstance = SimpleDateFormat.getDateInstance();
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        AlgsAnimalHanding algsAnimalHanding = algsAnimalHandingMapper.selectAlgsAnimalHandingByAnimalHandingId(animalHandingId);
        algsAnimalHanding.setAnimalHandingBy3("已处理");
        algsAnimalHanding.setAnimalHandingHandingTime(date);
        algsAnimalHanding.setAnimalHandingDesc("王小锤");
        AlgsHandingRecord algsHandingRecord = new AlgsHandingRecord();
        algsHandingRecord.setAnimalHandingId(algsAnimalHanding.getAnimalHandingId());
        algsHandingRecord.setAnimalHandingName(algsAnimalHanding.getAnimalHandingName());
        algsHandingRecord.setAnimalHandingHandingTime(date);
        algsAnimalHandingMapper.updateAlgsAnimalHanding(algsAnimalHanding);
        System.out.println(algsHandingRecord);
        return algsHandingRecordMapper.insertAlgsHandingRecord(algsHandingRecord);
    }
}
